<template>
	<view>
	<public-module></public-module>
	<view class="content">
	<u-empty :text="$t('nologin')" mode="data"  icon="https://i.yodin.com/storage/empty/permission.png" v-if="!hasLogin"></u-empty>
	<view v-else>
        
		<!--banner-->
		<view class="tui-banner-swiper">
			<view v-if="goods.images.length==0">
				
          <u--image
            :showLoading="true"
            :src="goods.cover_url"
            :lazy-load="true"
            :fade="true"
            duration="450"
            width="100%"
			v-if="goods.cover_url!=''">
			<template v-slot:loading><u-loading-icon ></u-loading-icon></template>
          </u--image>
				
			</view>
			<view v-else>
			<u-swiper :list="goods.images" keyName="file_url" height="220" :radius="0" circular radius="0"></u-swiper>
			</view>
		</view>
		
				<block class="">
					<view class="kait">
						<view class="kt_01">
							<img src="@/static/imgs/vip.png"></img>
						</view>
						<view class="kt_02">{{goods.name}}</view>
						<view class="kt_03" @click="clipboardcopy()">点击这里复制</view>
					</view>
				</block>
		

		<view class="t-box">
			<view>{{title}}</view>
			<!--view>
				<view class=""  v-for="(item, index) in goods.words" :key="index" v-if="goods.words.length > 0">
				 <view class="u-m-t-20">【{{item.file_name}}】{{item.file_url}}</view>
				</view>
				<view class=""  v-for="(item, index) in goods.others" :key="index" v-if="goods.others.length > 0">
				 <view class="u-m-t-20">【{{item.file_name}}】{{item.file_url}}</view>
				</view>
			</view-->
			<view ><u-parse :content="content" selectable></u-parse></view>
		</view>
		
		<view class="u-flex-col u-flex-middle dddd">
			<view><u--image src="https://i.yodin.com/storage/medcy.jpg" mode="widthFix" width="200" height="auto" radius="10"></u--image></view>
			<view>复制链接可获取文件，或加管理员微信接收。</view>
			<u-gap height="40"></u-gap>
		</view>
		<u-gap height="40"></u-gap>
	</view>

	</view>

	</view>
</template>

<script>

import socket from '@/plugins/socket.js';
import {mapState,mapMutations} from 'vuex';
import { api_goods_item } from '@/config/api.js';
export default {
    components:{
        
    },
	data() {
		return {
			loadstatus:false,
			loadStatus: "loadmore",
			hasLogin:false,
			goods_id:'',
			goods:{
				images:[],
				words:[],
				others:[]
			},
			title:'',
			content:''
		};
	},
	computed:{
	    ...mapState(['PrimaryColor','userInfo','siteInfo']),
	},
	onLoad(options) {
		this.hasLogin = this.userInfo.token;
		this.goods_id = options.id
		this.title=options.txt
		this.getGoodsInfo()
	},

	methods: {
		clipboardcopy(info) {
		 // let viewElement = document.getElementById('myViewId');
		  let that = this;
		// #ifdef MP

		// #endif

		  uni.setClipboardData({
			data: that.content,
			success: function (data) {
			  that.$tools.msg('信息复制成功')
			},
			fail: function (err) {that.$tools.msg('复制失败,请长按文字复制,如还不能,请加管理员微信,通过微信发送。')}
		  });
		},
           getGoodsInfo(){
				api_goods_item({
					goods_id:this.goods_id,
					is_full:1
				},{custom: {load:true}}
				).then((res) => {
					console.log("aaa",res)
					this.loadstatus=false
					this.goods=res
					
					
					if (this.goods.words && this.goods.words.length > 0) {
					  this.goods.words.forEach(item => {
						this.content += '【' + item.file_name + '】' + item.file_url + '\n';
					  });
					}

					if (this.goods.others && this.goods.others.length > 0) {
					  this.goods.others.forEach(item => {
						this.content += '【' + item.file_name + '】' + item.file_url + '\n';
					  });
					}
		
				}).catch((err) =>{})
            },

	},
	
};
</script>

<style lang="scss" scoped>
	.t-box {
		background: #f1f1f1;
		border-radius: 24upx;
		overflow: hidden;
		margin: 0px 20px;
		padding:20px;
		word-wrap: break-word;
	}
	.kait {
		margin: 10px;
		background-color: #F7F8FC;
		padding: 10px;
		border-radius: 30px;
		display: flex;
		font-size: 14px;

		.kt_01 {
			background-color: #000;
			border-radius: 50%;
			width: 25px;
			height: 25px;
			text-align: center;

			img {
				width: 18px;
				height: 18px;
				padding-top: 3px;
			}
		}

		.kt_02 {
			padding-left: 5px;
			height: 25px;
			line-height: 25px;
			flex-grow: 1;
		}

		.kt_03 {
			background-color: #000;
			color: #DDCFC2;
			height: 25px;
			line-height: 25px;
			border-radius: 15px;
			padding: 0 10px;
			font-size: 12px;
		}
	}
</style>
